#!/usr/bin/env python

# Entertainer backend - This is a server side of the Entertainer media center.
# Copyright (C) 2007 Lauri Taimila
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

__licence__ = "GPLv2"
__copyright__ = "2007, Lauri Taimila"
__author__ = "Lauri Taimila <lauri@taimila.com>"
__version__= "0.1"

import gobject
import os
import sys
from backend.backend_server import BackendServer

if __name__ == "__main__":
    if len(sys.argv) > 1 and (sys.argv[1] == "--help" or sys.argv[1] == "-h"):
        print "Entertainer backend " + str(__version__) + ", Copyright (c) " + str(__copyright__)
        print ""
        print "Usage:"
        print "    --help               - This help listing"
        print "    --foreground         - Run backend as foreground process"
        sys.exit(0)
    
    if len(sys.argv) > 1 and sys.argv[1] == "--foreground":
        backend = BackendServer()
    else:
        if os.fork() == 0:
            backend = BackendServer()
        else:
            print "Entertainer backend started..."
